package com.sljy.hzk.entity;

import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;
import android.arch.persistence.room.TypeConverter;
import android.arch.persistence.room.TypeConverters;
import android.support.annotation.NonNull;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.List;

/**
 * Created  on 2018/6/27 0027
 *
 * @author 唐开阔
 * @describe
 */
@Entity
public class UserEntity {
    /**
     * allPId : []
     * comPId : 5
     * roleId : 0
     * cpId : 501
     * name : 甄海鹏
     * pId : 34
     * position : 华大健康-华大分区2-工种测试
     * menu : [1,2,3]
     * userId : 14
     * isPermanent 0:1 是否为默认登录用户
     * accounts 账号
     * password 密码
     */
    private int comPId;
    private int roleId;
    private long cpId;
    private String name;
    private int pId;
    private String position;
    private String headPic;
    @PrimaryKey
    @NonNull
    private long userId;
    @Ignore
    private List<Integer> allPId;
    @Ignore
    private List<Integer> menu;
    private String menuStr;
    private int isPermanent = 1;
    private String accounts;
    private String password;
    private String idCard;

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getHeadPic() {
        if(headPic == null)
            headPic = "";
        return headPic;
    }

    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getIsPermanent() {
        return isPermanent;
    }

    public void setIsPermanent(int isPermanent) {
        this.isPermanent = isPermanent;
    }

    public String getAccounts() {
        return accounts;
    }

    public void setAccounts(String accounts) {
        this.accounts = accounts;
    }

    public String getMenuStr() {
        return menuStr;
    }

    public void setMenuStr(String menuStr) {
        this.menuStr = menuStr;
    }

    public int getComPId() {
        return comPId;
    }

    public void setComPId(int comPId) {
        this.comPId = comPId;
    }

    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    public long getCpId() {
        return cpId;
    }

    public void setCpId(long cpId) {
        this.cpId = cpId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPId() {
        return pId;
    }

    public void setPId(int pId) {
        this.pId = pId;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public List<Integer> getAllPId() {
        return allPId;
    }

    public void setAllPId(List<Integer> allPId) {
        this.allPId = allPId;
    }

    public List<Integer> getMenu() {
        return menu;

    }
    public List<Integer> getMenuList() {
        Gson gson = new Gson();
        return gson.fromJson(getMenuStr(), new TypeToken<List<Integer>>() {}.getType());

    }

    public void setMenu(List<Integer> menu) {
        this.menu = menu;
    }

}
